<html>
<head><meta charset="utf-8"><title>rustflags for all targets · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html">rustflags for all targets</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="246126220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246126220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246126220">(Jul 15 2021 at 17:14)</a>:</h4>
<p>Hi all, is there a way currently to specify a set of rust flags that apply to all targets, along with target-specific flags as well?</p>



<a name="246126361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246126361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246126361">(Jul 15 2021 at 17:15)</a>:</h4>
<p>For example, I'd expect to be able to put the common flags in the <code>[build]</code> section of config.toml, and then the target-specific flags in <code>[target.whatever]</code>, and have these two sets of flags get concatenated.</p>



<a name="246126517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246126517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246126517">(Jul 15 2021 at 17:16)</a>:</h4>
<p>But it looks like if there are flags from the target section, then the flags in the build section are not used.</p>



<a name="246126758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246126758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246126758">(Jul 15 2021 at 17:18)</a>:</h4>
<p>One workaround I found is to do <code>[target.'cfg(any(unix,not(unix)))']</code>, since the rustflags from all matching target sections get combined.</p>



<a name="246126770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246126770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246126770">(Jul 15 2021 at 17:18)</a>:</h4>
<p>I was wondering if there's a prettier way to do this though.</p>



<a name="246126871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246126871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246126871">(Jul 15 2021 at 17:19)</a>:</h4>
<p>And if not, would people be interested having a <code>[target.all]</code> or <code>[target.*]</code> section?</p>



<a name="246184804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246184804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246184804">(Jul 16 2021 at 04:58)</a>:</h4>
<p>Will <code>[target.'cfg(TRUE)']</code> do the trick?</p>



<a name="246185272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246185272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246185272">(Jul 16 2021 at 05:07)</a>:</h4>
<p>is <code>TRUE</code> actually a true cfg? I've seen <code>cfg(FALSE)</code> before, but that just works because nothing defines <code>FALSE</code> (and is defeated by <code>RUSTFLAGS="--cfg FALSE"</code>)</p>



<a name="246185323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246185323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246185323">(Jul 16 2021 at 05:08)</a>:</h4>
<p>To answer the question, <code>[target.'cfg(all())']</code> might work?</p>



<a name="246285477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rustflags%20for%20all%20targets/near/246285477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rustflags.20for.20all.20targets.html#246285477">(Jul 16 2021 at 21:57)</a>:</h4>
<p>Thanks for the suggestion. I just tried it out and <code>[target.'cfg(all())']</code> works. I think there's not any point in adding a special case for <code>[target.all]</code> then.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>